<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./lib/vue-2.5.9.js"></script>
  <!-- vue-resource 只能在 vue 的后面导入  -->
  <script src="./lib/vue-resource-1.3.4.js"></script>
</head>

<body>
  <div id="app">
    <input type="button" value="Get请求" @click="getInfo">
    <input type="button" value="Post请求" @click="postInfo">
    <input type="button" value="JSONP请求" @click="jsonpInfo">
  </div>

  <script>
    // 创建 Vue 实例，得到 ViewModel
    var vm = new Vue({
      el: '#app',
      data: {},
      methods: {
        /* getInfo() { // get方式请求数据
          this.$http.get('http://39.106.32.91:3000/api/getlunbo').then(function (data) {
            console.log(data.body)
          })
        } */

        async getInfo() {
          const { body } = await this.$http.get('http://39.106.32.91:3000/api/getlunbo')
          console.log(body)
        },

        async postInfo() {
          const { body } = await this.$http.post('http://39.106.32.91:3000/api/post', { name: '高婆婆', age: 22, gender: '妖人' })

          console.log(body)
        },

        async jsonpInfo() {
          const { body } = await this.$http.jsonp('http://39.106.32.91:3000/api/jsonp')
          console.log(body)
        }
      }
    });
  </script>
</body>

</html>